<template>
	<view class="foot">
		<image src="/static/tab/tabBack1.png" class="tabBack" />
		<view class="cu-bar tabbar foot">
			<view class="action " :class="selected==1?'text-cyan':''" @click="NavChange" data-cur="home">
				<view class="cuIcon-cu-image">
					<image :src="selected==1?'/static/tab/homefill.png':'/static/tab/home.png'"></image>
				</view>首页
			</view>
			<view class="action " :class="selected==2?'text-cyan':''" @click="NavChange" data-cur="articlelist">
				<view class="cuIcon-cu-image">
					<image :src="selected==2?'/static/tab/wefill.png':'/static/tab/we.png'"></image>
				</view>商城
			</view>
			<view class="action  add-action" :class="selected==3?'text-cyan':''" @click="NavChange" data-cur="join">
				<image src="@/static/tab/add.png" class="addimg"></image>
				<view class="">
					扫码支付
				</view>
			</view>
			<view class="action " :class="selected==3?'text-cyan':''" @click="NavChange" data-cur="news">
				<view class="cuIcon-cu-image">
					<image :src="selected==3?'/static/tab/messagefill.png':'/static/tab/message.png'"></image>
				</view>
				商户
			</view>
			<view class="action " :class="selected==4?'text-cyan':''" @click="NavChange" data-cur="my">
				<view class="cuIcon-cu-image">
					<image :src="selected==4?'/static/tab/myfill.png':'/static/tab/my.png'"></image>
				</view>
				我的
			</view>
		</view>

	</view>
</template>
<script>
	export default {
		props: {
			selected: { // 当前选中的tab index
				type: Number,
				default: 0

			},
			vering: {
				type: Number
			}
		},

		data() {
			return {
				color: "#333333",
				PageCur: '',
				selectedColor: "#d4237a",
				list: [{
						"pagePath": "pages/index/index",
						"text": "首页",
						"iconPath": "https://bj.bcebos.com/txy-dev/txy/main/down.png",
						"selectedIconPath": "/static/tab/homefill.png"
					},
					{
						"pagePath": "pages/index/home",
						"text": "服务",
						"iconPath": "/static/tab/we.png",
						"selectedIconPath": "https://bj.bcebos.com/txy-dev/txy/main/down.png"
					}, {
						"pagePath": "pages/index/home",
						"text": "商城",
						"iconPath": "/static/tab/message.png",
						"selectedIconPath": "https://bj.bcebos.com/txy-dev/txy/main/down.png"
					},
					{
						"pagePath": "pages/index/my",
						"text": "我的",
						"iconPath": "/static/tab/my.png",
						"selectedIconPath": "https://bj.bcebos.com/txy-dev/txy/main/txy.png"
					}
				]
			}
		},
		onShow() {
			var PageCur = uni.getStorageSync('PageCur')
			if (!PageCur) {
				PageCur = 'home'
			} else {
				this.PageCur = PageCur
			}

		},
		created() {
			var PageCur = uni.getStorageSync('PageCur')
			if (!PageCur) {
				PageCur = 'home'
			} else {
				this.PageCur = PageCur
			}
		},

		methods: {
			switchTab(item, index) {
				console.log("item", item)
				console.log("index", index)
				let url = item.pagePath;
				// 对应患者和医生的首页
				if (index == 0) {
					url = "/pages/index/index"
				}
				// 对应患者和医生的我的页面
				if (index == 1) {
					url = "/pages/index/my"
				}
				if (index == 2) {
					uni.navigateToMiniProgram({
						appId: 'wxac06eaffe466baa3',
					})

					return
				}
				if (index == 3) {
					url = "/pages/index/my"
				}
				uni.switchTab({
					url
				})
			},
			NavChange: function(e) {
				console.log(e);
				let url = '';
				this.PageCur = e.currentTarget.dataset.cur
				if (this.PageCur == 'home') {
					url = "/pages/index/index"
				}
				if (this.PageCur == 'articlelist') {
					url = "/pages/index/my"
				}
				if (this.PageCur == 'join') {

				}
				if (this.PageCur == 'news') {
					url = "/pages/shanghu/shanghu"
				}
				if (this.PageCur == 'my') {
					url = "/pages/center/index"
				}
				uni.setStorageSync('PageCur', this.PageCur)
				console.log(url);
				uni.switchTab({
					url: url
				})
			}
		}
	}
</script>

<style lang="less">
	.tab-bar {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 100rpx;
		background: white;
		display: flex;
		justify-content: center;
		align-items: center;
		padding-bottom: env(safe-area-inset-bottom); // 适配iphoneX的底部

		.tab-bar-item {
			flex: 1;
			text-align: center;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;

			.tab_img {
				width: 37rpx;
				height: 41rpx;
			}

			.tab_text {
				font-size: 20rpx;
				margin-top: 9rpx;
			}
		}
	}

	body {
		background-color: #fff;
		font-size: 28rpx;
		color: #333333;
		font-family: Helvetica Neue, Helvetica, sans-serif;
	}

	view,
	scroll-view,
	swiper,
	button,
	input,
	textarea,
	label,
	navigator,
	image {
		box-sizing: border-box;
	}

	.round {
		border-radius: 5000rpx;
	}

	.radius {
		border-radius: 6rpx;
	}

	.bg-red {
		background-color: #e54d42;
		color: #ffffff;
	}

	.bg-orange {
		background-color: #f37b1d;
		color: #ffffff;
	}

	.bg-yellow {
		background-color: #fbbd08;
		color: #333333;
	}

	.bg-olive {
		background-color: #8dc63f;
		color: #ffffff;
	}

	.bg-green {
		background-color: #39b54a;
		color: #ffffff;
	}

	.bg-cyan {
		background-color: #1cbbb4;
		color: #ffffff;
	}

	.bg-blue {
		background-color: #0081ff;
		color: #ffffff;
	}


	.bg-grey {
		background-color: #8799a3;
		color: #ffffff;
	}

	.bg-gray {
		background-color: #f0f0f0;
		color: #333333;
	}

	.bg-black {
		background-color: #333333;
		color: #ffffff;
	}


	.text-cyan,
	.line-cyan,
	.lines-cyan {
		color: #D81E06;
	}

	/* ==================
	          操作条
	 ==================== */
	.tabBack {
		width: 100% !important;
		height: 230rpx !important;
		z-index: 1;
		position: absolute;
		bottom: -80rpx;
	}

	.addimg {
		width: 106rpx !important;
		height: 106rpx !important;
	}

	.cu-bar {
		display: flex;
		position: relative;
		align-items: flex-end;
		min-height: 100rpx;
		justify-content: space-between;
	}

	.cu-bar .action {
		display: flex;
		align-items: center;
		height: 100%;


		justify-content: center;
		max-width: 100%;
	}

	.cu-bar .action.border-title {
		position: relative;
		top: -10rpx;
	}

	.cu-bar .action.border-title text[class*="bg-"]:last-child {
		position: absolute;
		bottom: -0.5rem;
		min-width: 2rem;
		height: 6rpx;
		left: 0;
	}

	.cu-bar .action.sub-title {
		position: relative;
		top: -0.2rem;
	}

	.cu-bar .action.sub-title text {
		position: relative;
		z-index: 1;
	}

	.cu-bar .action.sub-title text[class*="bg-"]:last-child {
		position: absolute;
		display: inline-block;
		bottom: -0.2rem;
		border-radius: 6rpx;
		width: 100%;
		height: 0.6rem;
		left: 0.6rem;
		opacity: 0.3;
		z-index: 0;
	}

	.cu-bar .action.sub-title text[class*="text-"]:last-child {
		position: absolute;
		display: inline-block;
		bottom: -0.7rem;
		left: 0.5rem;
		opacity: 0.2;
		z-index: 0;
		text-align: right;
		font-weight: 900;
		font-size: 36rpx;
	}

	.cu-bar.justify-center .action.border-title text:last-child,
	.cu-bar.justify-center .action.sub-title text:last-child {
		left: 0;
		right: 0;
		margin: auto;
		text-align: center;
	}

	.cu-bar .action:first-child {
		margin-left: 30rpx;
		font-size: 30rpx;
	}

	.cu-bar .action text.text-cut {
		text-align: left;
		width: 100%;
	}

	.cu-bar .cu-avatar:first-child {
		margin-left: 20rpx;
	}

	.cu-bar .action:first-child>text[class*="cuIcon-"] {
		margin-left: -0.3em;
		margin-right: 0.3em;
	}

	.cu-bar .action:last-child {
		margin-right: 30rpx;
	}

	.cu-bar .action>text[class*="cuIcon-"],
	.cu-bar .action>view[class*="cuIcon-"] {
		font-size: 36rpx;
	}

	.cu-bar .action>text[class*="cuIcon-"]+text[class*="cuIcon-"] {
		margin-left: 0.5em;
	}

	.cu-bar .content {
		position: absolute;
		text-align: center;
		width: calc(100% - 340rpx);
		left: 0;
		right: 0;
		bottom: 0;
		top: 0;
		margin: auto;
		height: 60rpx;
		font-size: 32rpx;
		line-height: 60rpx;
		cursor: none;
		pointer-events: none;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}

	.cu-bar.ios .content {
		bottom: 7px;
		height: 30px;
		font-size: 32rpx;
		line-height: 30px;
	}

	.cu-bar.btn-group {
		justify-content: space-around;
	}

	.cu-bar.btn-group button {
		padding: 20rpx 32rpx;
	}

	.cu-bar.btn-group button {
		flex: 1;
		margin: 0 20rpx;
		max-width: 50%;
	}

	.cu-bar .search-form {
		background-color: #f5f5f5;
		line-height: 64rpx;
		height: 64rpx;
		font-size: 24rpx;
		color: #333333;
		flex: 1;
		display: flex;
		align-items: center;
		margin: 0 30rpx;
	}

	.cu-bar .search-form+.action {
		margin-right: 30rpx;
	}

	.cu-bar .search-form input {
		flex: 1;
		padding-right: 30rpx;
		height: 64rpx;
		line-height: 64rpx;
		font-size: 26rpx;
		background-color: transparent;
	}

	.cu-bar .search-form [class*="cuIcon-"] {
		margin: 0 0.5em 0 0.8em;
	}

	.cu-bar .search-form [class*="cuIcon-"]::before {
		top: 0rpx;
	}

	.cu-bar.fixed,
	.nav.fixed {
		position: fixed;
		width: 100%;
		top: 0;
		z-index: 1024;
		box-shadow: 0 1rpx 6rpx rgba(0, 0, 0, 0.1);
	}

	.foot {
		position: fixed;
		width: 100%;
		height: 100rpx;
		// height: calc(132rpx + env(safe-area-inset-bottom) / 2);
		bottom: 0;
		margin-bottom: 40rpx;
		z-index: 1024;
	}

	.cu-bar.tabbar {
		// margin-bottom: 50rpx;
		padding: 0;
		// height: calc(132rpx + env(safe-area-inset-bottom) / 2);
		height: 100rpx;
		// padding-bottom: constant(safe-area-inset-bottom);
		// padding-bottom: env(safe-area-inset-bottom);
	}

	.cu-tabbar-height {
		min-height: 100rpx;
		height: calc(120rpx + env(safe-area-inset-bottom) / 2);
	}

	.cu-bar.tabbar.shadow {
		box-shadow: 0 -1rpx 6rpx rgba(0, 0, 0, 0.1);
	}

	.cu-bar.tabbar .action {
		font-size: 22rpx;
		position: relative;
		flex: 1;
		text-align: center;
		padding: 0;
		display: block;
		height: auto;
		line-height: 1;
		margin: 0;
		background-color: inherit;
		overflow: initial;
		padding-top: 10rpx;
	}

	.cu-bar.tabbar.shop .action {
		width: 140rpx;
		flex: initial;
	}

	.cu-bar.tabbar .action.add-action {
		position: relative;
		z-index: 2;
		margin-top: -30rpx;
	}

	.cu-bar.tabbar .action.add-action [class*="cuIcon-"] {
		position: absolute;
		width: 70rpx;
		z-index: 2;
		height: 70rpx;
		border-radius: 50%;
		line-height: 70rpx;
		font-size: 50rpx;
		top: -35rpx;
		left: 0;
		right: 0;
		margin: auto;
		padding: 0;
	}

	.cu-bar.tabbar .btn-group {
		flex: 1;
		display: flex;
		justify-content: space-around;
		align-items: center;
		padding: 0 10rpx;
	}

	.cu-bar.tabbar button.action::after {
		border: 0;
	}

	.cu-bar.tabbar .action [class*="cuIcon-"] {
		width: 100rpx;
		position: relative;
		display: block;
		height: auto;
		margin: 0 auto 10rpx;
		text-align: center;
		font-size: 40rpx;
	}

	.cu-bar.tabbar .action .cuIcon-cu-image {
		margin: 0 auto;
	}

	.cu-bar.tabbar .action .cuIcon-cu-image image {
		width: 36rpx;
		height: 36rpx;
		display: inline-block;
		margin-bottom: 10rpx;
	}

	.cu-bar.tabbar .submit {
		align-items: center;
		display: flex;
		justify-content: center;
		text-align: center;
		position: relative;
		flex: 2;
		align-self: stretch;
	}

	.cu-bar.tabbar .submit:last-child {
		flex: 2.6;
	}

	.cu-bar.tabbar .submit+.submit {
		flex: 2;
	}

	.cu-bar.tabbar.border .action::before {
		content: " ";
		width: 200%;
		height: 200%;
		position: absolute;
		top: 0;
		left: 0;
		transform: scale(0.5);
		transform-origin: 0 0;
		border-right: 1rpx solid rgba(0, 0, 0, 0.1);
		z-index: 3;
	}

	.cu-bar.tabbar.border .action:last-child:before {
		display: none;
	}

	.cu-bar.input {
		padding-right: 20rpx;
		background-color: #ffffff;
	}

	.cu-bar.input input {
		overflow: initial;
		line-height: 64rpx;
		height: 64rpx;
		min-height: 64rpx;
		flex: 1;
		font-size: 30rpx;
		margin: 0 20rpx;
	}

	.cu-bar.input .action {
		margin-left: 20rpx;
	}

	.cu-bar.input .action [class*="cuIcon-"] {
		font-size: 48rpx;
	}

	.cu-bar.input input+.action {
		margin-right: 20rpx;
		margin-left: 0rpx;
	}

	.cu-bar.input .action:first-child [class*="cuIcon-"] {
		margin-left: 0rpx;
	}
</style>
